This simulation system can simulate one robot soccer player for Robo\-Cup Middle Size League. It can be adapted for other purposes.

\section*{Recommended Operating Environment}


\begin{DoxyEnumerate}
\item Ubuntu 14.\-04;
\item R\-O\-S Indigo or R\-O\-S Jade.
\item Gazebo 5.\-0 or 5.\-1 or 7.\-1;
\item gazebo\-\_\-ros\-\_\-pkgs;
\end{DoxyEnumerate}

\begin{quotation}
{\bfseries N\-O\-T\-E\-:} If you choose \char`\"{}desktop-\/full\char`\"{} install of R\-O\-S Indigo, there is a Gazebo 2.\-0 included initially. In order to install Gazebo 5.\-0/5.1, you should first remove Gazebo 2.\-0 by running\-:

\end{quotation}
{\ttfamily \$ sudo apt-\/get remove gazebo2$\ast$} \begin{quotation}
Then you should be able to install Gazebo 5.\-0 now. To install gazebo\-\_\-ros\-\_\-pkgs compatible with Gazebo 5.\-0/5.1, run this command\-:

\end{quotation}
{\ttfamily \$ sudo apt-\/get install ros-\/indigo-\/gazebo5-\/ros-\/pkgs ros-\/indigo-\/gazebo5-\/ros-\/control}

Other versions of Ubuntu, R\-O\-S or Gazebo may also work, but we have not tested yet.

\begin{quotation}
{\bfseries Update\-:} It seems {\ttfamily \$ sudo apt-\/get install ros-\/indigo-\/gazebo5-\/ros-\/pkgs ros-\/indigo-\/gazebo5-\/ros-\/control} no longer works now. These packages may be moved to other places. You can checkout \href{https://github.com/ros-simulation/gazebo_ros_pkgs.git,}{\tt https\-://github.\-com/ros-\/simulation/gazebo\-\_\-ros\-\_\-pkgs.\-git,} download and install this package. A workaround is installing R\-O\-S Jade, which has gazebo\-\_\-ros\-\_\-pkgs in it; so you don't have to install it again. However, you should do the following steps to fix some of the bugs in R\-O\-S Jade\-:

\end{quotation}


\begin{quotation}
(a) {\ttfamily \$ sudo gedit /opt/ros/jade/lib/gazebo\-\_\-ros/gazebo} In this file, go to line 24 and delete the last '/'. So {\ttfamily setup\-\_\-path=\$(pkg-\/config -\/-\/variable=prefix gazebo)/share/gazebo/} is changed to {\ttfamily setup\-\_\-path=\$(pkg-\/config -\/-\/variable=prefix gazebo)/share/gazebo} You can read this link for more information\-: \char`\"{}http\-://answers.\-ros.\-org/question/215796/problem-\/for-\/install-\/gazebo\-\_\-ros\-\_\-package/\char`\"{} (b) Install Gazebo 5. {\ttfamily \$ sudo apt-\/get install gazebo5} If this fails, try to run the 'gazebo5\-\_\-install.\-sh' in this directoy. Read for more information \char`\"{}http\-://answers.\-ros.\-org/question/217970/ros-\/jade-\/and-\/gazebo-\/50-\/migration-\/problem/\char`\"{} (c) Optional\-: copy resource files to the new gazebo folder. {\ttfamily \$ sudo cp -\/r /usr/share/gazebo-\/5.0/$\ast$ /usr/share/gazebo-\/5.1}

\end{quotation}


\section*{Complie}


\begin{DoxyEnumerate}
\item Go to the package root directory (single\-\_\-nubot\-\_\-gazebo)
\item If you already have C\-Make\-Lists.\-txt in the \char`\"{}src\char`\"{} folder, then you can skip this step. If not, run these commands\-:

``` \$ cd src \$ catkin\-\_\-init\-\_\-workspace \$ cd .. ```
\item \$ ./configure
\item \$ catkin\-\_\-make --pkg \hyperlink{namespacenubot__common}{nubot\-\_\-common}
\item \$ catkin\-\_\-make
\end{DoxyEnumerate}

\section*{Tutorials}

\subsection*{Part I. Overview}

The robot movement is realized by a Gazebo model plugin which is called \char`\"{}\-Nubot\-Gazebo\char`\"{} generated by source files \char`\"{}nubot\-\_\-gazebo.\-cc\char`\"{} and \char`\"{}nubot\-\_\-gazebo.\-hh\char`\"{}. Basically the essential part of the plugin is realizing basic motions\-: omnidirectional locomotion, ball-\/dribbling and ball-\/kicking.

Basically, this plugin subscribes to topic \char`\"{}nubotcontrol/velcmd\char`\"{} for omnidirecitonal movement and subscribes to service \char`\"{}\-Ball\-Handle\char`\"{} and \char`\"{}\-Shoot\char`\"{} for ball-\/dribbling and ball-\/kicking respectively. You can customize this code for your robot based on these messages and services as a convenient interface.

As for ball-\/dribbling, there are three ways for a robot to dribble a ball, i.\-e.

\begin{TabularC}{2}
\hline
\rowcolor{lightgray}\PBS\centering {\bf Method }&{\bf Description  }\\\cline{1-2}
\PBS\centering (a) Setting ball pose continually &This is the most accurate one; nubot would hardly lose control of the ball, but the visual effect is not very good (the ball does not rotate). \\\cline{1-2}
\PBS\centering (b) Setting ball secant velocity &This is less acurate than method (a) but more accurate than method (c). \\\cline{1-2}
\PBS\centering (c) Setting ball tangential velocity &This is the least accurate. If the robot moves fast, such as 3 m/s, it would probably lose control of the ball. However, this method achieves the best visual effect under low-\/speed condition. \\\cline{1-2}
\end{TabularC}
{\bfseries By default, we use method (c) for ball-\/dribbling.}

As for Gaussian noise, {\bfseries by default, Gaussian noise is N\-O\-T added}, but you can add it by changing the flag in \hyperlink{nubot__gazebo_8cc}{nubot\-\_\-gazebo.\-cc} in function update\-\_\-model\-\_\-info();

Please read the paper \char`\"{}\-Weijia Yao et al., A Simulation System Based on R\-O\-S and Gazebo for Robo\-Cup Middle Size League, 2015\char`\"{} for more information.

\subsection*{Part I\-I. Single robot automatic movement}

The robot will do motions according to states transfer graph. Steps are as follows\-:
\begin{DoxyEnumerate}
\item Go to the package root directory (single\-\_\-nubot\-\_\-gazebo)
\item source the setup.\-bash file\-: {\ttfamily \$ source devel/setup.\-bash}
\item {\ttfamily \$ roslaunch \hyperlink{namespacenubot__gazebo}{nubot\-\_\-gazebo} sdf\-\_\-nubot.\-launch}
\end{DoxyEnumerate}

\begin{quotation}
{\bfseries Note\-:} Every time you open a new terminal, you have to do step 2. You can also write this command into the $\sim$/.bashrc file so that you don't have to source it every time.

\end{quotation}


Finally, the robot rotates and translates with trajectory planning. That is, the robot accelerates at constant acceleration and stays at constant speed when it reaches the maximum velocity.

\subsection*{Part I\-I\-I. Keyboad control robot movement}


\begin{DoxyEnumerate}
\item In \hyperlink{nubot__gazebo_8cc}{nubot\-\_\-gazebo.\-cc}, comment \char`\"{}nubot\-\_\-auto\-\_\-control();\char`\"{} and uncomment \char`\"{}nubot\-\_\-be\-\_\-control();\char`\"{} in function Update\-Child().
\item Compile again and follow steps 1-\/3 listed in Part I\-I.
\item {\ttfamily \$ rosrun \hyperlink{namespacenubot__gazebo}{nubot\-\_\-gazebo} nubot\-\_\-teleop\-\_\-keyboard}
\end{DoxyEnumerate}

\subsection*{Part I\-V. Appendix}


\begin{DoxyEnumerate}
\item To launch an empty soccer field\-: {\ttfamily \$ roslaunch \hyperlink{namespacenubot__gazebo}{nubot\-\_\-gazebo} empty\-\_\-field.\-launch}
\item To launch the simulation world with rqt\-\_\-plot of nubot or ball's velocity\-: {\ttfamily \$ roslaunch \hyperlink{namespacenubot__gazebo}{nubot\-\_\-gazebo} sdf\-\_\-nubot.\-launch plot\-:=true}
\end{DoxyEnumerate}

\subsection*{Q\&A}


\begin{DoxyEnumerate}
\item How to use Gazebo 5 in R\-O\-S Jade? (This code works in R\-O\-S jade) It seems there is a bug in the configuration of Gazebo 5.\-0 in R\-O\-S Jade. So the solution is as follows(steps)\-: (a) {\ttfamily \$ sudo gedit /opt/ros/jade/lib/gazebo\-\_\-ros/gazebo}. In this file, go to line 24 and delete the last '/'. So 'setup\-\_\-path=\$(pkg-\/config --variable=prefix gazebo)/share/gazebo/' is changed to 'setup\-\_\-path=\$(pkg-\/config --variable=prefix gazebo)/share/gazebo'. You can read this link for more information\-: '\href{http://answers.ros.org/question/215796/problem-for-install-gazebo_ros_package/'}{\tt http\-://answers.\-ros.\-org/question/215796/problem-\/for-\/install-\/gazebo\-\_\-ros\-\_\-package/'} (b) Install Gazebo 5. {\ttfamily \$ sudo apt-\/get install gazebo5}. If this fails, try to run the 'gazebo5\-\_\-install.\-sh' in this directoy. Read for more information\-: '\href{http://answers.ros.org/question/217970/ros-jade-and-gazebo-50-migration-problem/'}{\tt http\-://answers.\-ros.\-org/question/217970/ros-\/jade-\/and-\/gazebo-\/50-\/migration-\/problem/'} (c) Optional\-: copy resource files to the new gazebo folder. {\ttfamily \$ sudo cp -\/r /usr/share/gazebo-\/5.0/$\ast$ /usr/share/gazebo-\/5.1}
\item How to install gazebo 7.\-1 and gazebo\-\_\-ros\-\_\-pkgs with R\-O\-S Jade? (1) Install R\-O\-S jade; (2) Go to gazebosim.\-org and install gazebo 7.\-0; (3) Go to the github website and download the repository of gazebo\-\_\-ros\-\_\-pkgs on the branch 'kinetic-\/devel'\-: {\ttfamily \$ git clone \href{https://github.com/ros-simulation/gazebo_ros_pkgs.git}{\tt https\-://github.\-com/ros-\/simulation/gazebo\-\_\-ros\-\_\-pkgs.\-git} -\/b kinetic-\/devel} (4) Go to gazebo\-\_\-ros\-\_\-pkgs and create src/, put all other files or folders inside src/. {\ttfamily \$ cd src/} {\ttfamily \$ catkin\-\_\-init\-\_\-workspace} (5) To install dependencies, run {\ttfamily \$ cd ../../} {\ttfamily \$ rosdep install -\/-\/from-\/paths gazebo\-\_\-ros\-\_\-pkgs -\/-\/ignore-\/src -\/-\/rosdistro=R\-O\-S\-D\-I\-S\-T\-R\-O}. Here, R\-O\-S\-D\-I\-S\-T\-R\-O is the distribution of your R\-O\-S, such as jade or kinetic. (6) Then install all these files to /opt/ros/jade {\ttfamily \$ cd gazeo\-\_\-ros\-\_\-pkgs} {\ttfamily \$ catkin\-\_\-make -\/\-D\-C\-M\-A\-K\-E\-\_\-\-I\-N\-S\-T\-A\-L\-L\-\_\-\-P\-R\-E\-F\-I\-X=/opt/ros/jade install} 
\end{DoxyEnumerate}